package com.phoenix.callAnalysis;

import com.phoenix.callAnalysis.models.LoadDataFlag;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.widget.TextView;

public class SplashActivity extends Activity {
	private static final String TAG = SplashActivity.class.getSimpleName();

	private TextView tv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.d(TAG, "onCreate...");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		tv = (TextView) findViewById(R.id.loading_textView);
		new CountDownTimer(3000, 1000) {
			@Override
			public void onFinish() {
				launchCallAnalysisActivity();
			}

			@Override
			public void onTick(long millisUntilFinished) {
				tv.setText("seconds remaining: " + millisUntilFinished / 1000);
			}

		}.start();
	}

	@Override
	public void onBackPressed() {
	}

	private void launchCallAnalysisActivity() {
		if (CallAnalysisApplication.needLoadData == LoadDataFlag.NO_NEED) {
			startActivity(new Intent(this, CallAnalysisActivity.class));
		} else {
			startActivity(new Intent(this, LoadDataActivity.class));
		}
		finish();
	}

}
